package com.apep.gw.service.impl;

import com.apep.gw.service.OperateRecordService;
import com.apep.gw.service.StuationAnalyse;
import com.apep.gw.util.OperateType;
import com.hitrust.gs.bean.GSOperateRecord;
import com.hitrust.gs.util.exception.GSException;

public class ProductStuationAnalyse implements StuationAnalyse{

	OperateRecordService operateRecordService = new OperateRecordServiceImpl();

	public boolean changePrice(String content,String time,String userId,String userName,String recordId) throws GSException {
		int operateType = OperateType.productChangePrice;
		GSOperateRecord  vo =putOperateRecord(content, time, userId, userName, recordId,
				operateType);
		return operateRecordService.insertOperate(vo);
	}	
	
	public boolean open(String content,String time,String userId,String userName,String recordId) throws GSException {
		int operateType = OperateType.productOpen;
		GSOperateRecord  vo =putOperateRecord(content, time, userId, userName, recordId,
				operateType);
		return operateRecordService.insertOperate(vo);
	}

	
	public boolean close(String content,String time,String userId,String userName,String recordId) throws GSException {
		int operateType = OperateType.productClose;
		GSOperateRecord  vo =putOperateRecord(content, time, userId, userName, recordId,
				operateType);
		return operateRecordService.insertOperate(vo);
	}

	public boolean insert(String content,String time,String userId,String userName,String recordId) throws GSException {
		int operateType = OperateType.productInsert;
		GSOperateRecord  vo =putOperateRecord(content, time, userId, userName, recordId,
				operateType);
		return operateRecordService.insertOperate(vo);
	}

	public boolean update(String content,String time,String userId,String userName,String recordId) throws GSException {
		int operateType = OperateType.productUpdate;
		GSOperateRecord  vo =putOperateRecord(content, time, userId, userName, recordId,
				operateType);
		return operateRecordService.insertOperate(vo);
	}
	
	private GSOperateRecord putOperateRecord(String content, String time, String userId,
			String userName, String recordId, int operateType) {
		GSOperateRecord vo = new GSOperateRecord();
		vo.setOPERATE_TYPE(operateType);
		vo.setOPERATE_CONTENT(content);
		vo.setOPERATE_TIME(time);
		vo.setOPERATE_USER_ID(userId);
		vo.setOPERATE_USER_NAME(userName);
		vo.setSTATUS("1");
		vo.setREMARK("");
		vo.setRECORD_ID(recordId);

		return vo;
	}

}
